<?php

namespace App\Http\Controllers;

use App\Models\Site;
use App\Setting;

class IndexController extends Controller
{
    public function index()
    {
        $settings = Setting::getSettings()->whereIn('slug', ['admin_name', 'dept_name', 'user_name', 'site_name', 'site_desc'])->pluck('value', 'slug');
        $sites = Site::allCollection()->where('enabled',1)->map(function($item){
            return [
                'href'=>url($item['prefix']),
                'name'=>$item['name'],
                'img'=>$item['icon'],
            ];
        });
        $article = [
            'title'   => $settings->get('site_name') ?: '知识产权与科技成果转化平台',
            'content' => $settings->get('site_desc')
        ];
        return view('index', compact('sites', 'article'));
    }
}
